package com.gxar.quick.ar.server.base.model.user.mapper;

import com.gxar.common.entity.login.UserProfile;
import com.gxar.quick.ar.server.base.model.user.vo.UserInfoVO;
import com.gxar.quick.ar.server.base.model.user.vo.response.AdminUserPageResponse;
import com.gxar.quick.ar.server.base.model.user.vo.response.UserInfoResponse;
import com.gxar.quick.ar.server.db.model.UserInfoEntity;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 用户转换工具
 *
 * @author Linsy
 * @version 1.0
 * @created 2023/11/8 10:45 AM
 */
@Mapper
public interface UserMapStruct {

    UserMapStruct INSTANCE = Mappers.getMapper(UserMapStruct.class);

    /**
     * 用户信息转换
     *
     * @param entity 实体
     * @return 响应
     */
    @Mapping(target = "userId", expression = "java(String.valueOf(entity.getUserId()))")
    @Mapping(target = "comboId", expression = "java(String.valueOf(entity.getComboId()))")
    UserInfoResponse entityToInfoResponse(UserInfoEntity entity);

    /**
     * 用户信息转分页响应
     *
     * @param entity 用户信息
     * @return 响应
     */
    @Mapping(target = "id", expression = "java(String.valueOf(entity.getId()))")
    AdminUserPageResponse entityToPageResponse(UserInfoEntity entity);

    /**
     * 用户信息转分页响应
     *
     * @param userInfoEntityList 用户信息
     * @return 响应
     */
    List<AdminUserPageResponse> entitiesToPageResponses(List<UserInfoEntity> userInfoEntityList);

    /**
     * 用户信息转换
     *
     * @param userProfile 用户信息
     * @return 用户信息
     */
    @Mapping(target = "phone", source = "mobile")
    @Mapping(target = "userId", source = "id")
    UserInfoVO profileToInfo(UserProfile userProfile);

    /**
     * 用户信息转换
     *
     * @param userProfile 用户信息
     * @return 用户信息
     */
    List<UserInfoVO> profilesToInfos(List<UserProfile> userProfile);


}
